﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

namespace NXBSaiGon.Admin
{
    public partial class ConfirmAdmin1 : System.Web.UI.Page
    {
        private SqlConnection conn = new SqlConnection(ConfigurationManager
                                                        .ConnectionStrings["NXBSaiGonConnectionString1"]
                                                        .ConnectionString);
            
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlCommand cmd = new SqlCommand("SELECT CMND "
                                                + "FROM KhachHang "
                                                + "WHERE Username = 'admin' ", conn);
            conn.Open();
            string CMND = (string)cmd.ExecuteScalar();
            conn.Close();

            if (TextBoxConfirm.Text.CompareTo(CMND) == 0)
            {
                Session["username"] = "admin";
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                Session["username"] = null;
                Response.Redirect("~/Account/Login.aspx");
            }
        }
    }
}